package com.menusifu.onlineorder.order.service;


import com.alibaba.fastjson.JSONObject;
import com.menusifu.onlineorder.mongo.dao.OrderBillDao;
import com.menusifu.onlineorder.mongo.domain.OrderBill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class OrderBillService {

    @Autowired
    OrderBillDao orderBillDao;

    @Transactional("mongoTransaction")
    public void saveOrderBill(){
        OrderBill orderBill=new OrderBill();
        orderBill.setId(102L);
        orderBill.setNotes("测试订单");
        orderBill.setCreatedTime("2020-04-05 20:25:30");
        orderBillDao.save(orderBill);
        OrderBill orderBill2=new OrderBill();
        orderBill2.setId(103L);
        orderBill2.setNotes("测试订单");
        orderBill2.setCreatedTime("2020-04-05 20:25:30");
        orderBillDao.save(orderBill2);
    }


    public void findAllOrder(){
     List<OrderBill  > list=orderBillDao.findAll();

     for (OrderBill orderBill:list){
         System.out.println(JSONObject.toJSON(orderBill));
     }
    }



}
